package cn.wk.client;

import cn.wk.AjaxResult;
import cn.wk.domain.Movie;
import cn.wk.dto.MovieDto;
import cn.wk.exception.GlobalException;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class MovieFeignFallback implements FallbackFactory<MovieFeign> {
    @Override
    public MovieFeign create(Throwable throwable) {
        return new MovieFeign() {
            @Override
            public AjaxResult goBuy(Movie movie) {
                System.out.println("--------------走了feign的回调------------------");
                return AjaxResult.me().setSuccess(false).setMessage("走了feign的回调").setResultObj("走了feign的回调~");
            }

            @Override
            public void updateTicked(MovieDto movieDto) {
                throw new GlobalException("更新票数失败");
            }
        };
    }
}
